﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MikeKappel.Com.CS
{
    public static partial class Helper
    {
        public static Boolean IsEqual<T>(T item1, T item2)
        {
            if (ReferenceEquals(item1, item2))
                return true;

            if (item1 == null || item2 == null)
                return false;

            if (typeof(T).IsArray)
            {
                if ((item1 as Array).Length != (item2 as Array).Length)
                    return false;

                //EqualityComparer<T> comparer = EqualityComparer<T>.Default;
                for (int i = 0; i < (item1 as Array).Length; i++)
                {
                    if (!(item1 as Array).GetValue(i).Equals((item2 as Array).GetValue(i))) 
                        return false;
                }
            }
            else
            {
                throw new Exception("Type not yet supported");
            }
            return true;
        }
    }
}
